﻿using System;
using System.Collections.Generic;
using System.Text;

namespace MaximServices.Common
{
    public class DateTimeExt
    {
        public static double ConvertDateTimeInt(DateTime date)
        {
            double result = 0;
            DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            result = (date - startTime).TotalSeconds;
            return result;
        }

        public static DateTime GetTime(double timeStamp)
        {
            DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
            long lTime = long.Parse($"{timeStamp}0000000");
            TimeSpan toNow = new TimeSpan(lTime);
            return dtStart.Add(toNow);
        }
    }
}
